﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Web.Services;
using System.Threading;
using System.Runtime.InteropServices;
using System.Diagnostics;
using System.IO;
using System.Data;
using System.Data.SqlClient;
using System.Collections.Generic;
using EShop.BussinessObjects;
using EShop.Common;
using EShop.DataAccess;


public partial class _Default : BaseThemePage
{
   
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            Company _company = CGlobalData.GetCurrentCompany();
            if (_company != null)
            {
                divFacebook.Visible = _company.IsShowFb;
            }

            this.GenerateSlideShowItems();
        }
    }

    public string GetFBurl
    {
        get
        {
            Company company=new Company();
            company=CGlobalData.GetCurrentCompany();
            if (company != null)
                return "https://www.facebook.com/plugins/likebox.php?href=" + Server.UrlEncode(company.FbuRl) + "&width=350&colorscheme=light&connections=4&stream=false&header=false&height=200";
            else
                return "";
        }
    }

    public string GetDeliveryDistricts
    {
        get
        {
            CompanyDeliveryDistrict companyDeliveryDistrict = new CompanyDeliveryDistrict();

            companyDeliveryDistrict.ID = (int)cnstDatabase.DBOperationResult.ValueIsNotEffective;

            companyDeliveryDistrict.Company = new Company();
            companyDeliveryDistrict.Company.ID = CGlobalData.GetCurrentCompanyID();
            companyDeliveryDistrict.PostalCode = ((int)cnstDatabase.DBOperationResult.ValueIsNotEffective).ToString();

            List<CompanyDeliveryDistrict> coverdareasList = CDACompanyDeliveryDistrict.Select(companyDeliveryDistrict);

            string DeliveryDistricts = "";
            for (int i = 0; i < coverdareasList.Count; i++)
            {
                if (i == coverdareasList.Count - 1)
                    DeliveryDistricts += coverdareasList[i].PostalCode;
                else
                    DeliveryDistricts += coverdareasList[i].PostalCode + ",";
            }
            return DeliveryDistricts;
        }
    }


    private void GenerateSlideShowItems()
    {
        int Noteffective=(int)cnstDatabase.DBOperationResult.ValueIsNotEffective;
        CompanyConstant companyconstant = new CompanyConstant();
        companyconstant.ID = Noteffective;
        companyconstant.Company = new Company();
        companyconstant.Company.ID = CGlobalData.GetCurrentCompanyID();

        companyconstant.Constants=new Constants();
        companyconstant.Constants.ID=cnstConstants.SlideShow;
        
        List<CompanyConstant> companyconstantslist = CDACompanyConstant.Select(companyconstant);

        string li="";
        foreach(CompanyConstant _companyconstant in companyconstantslist)
        {
            li+="<li><img src='App_Themes\\" + Page.Theme + "\\images\\SlideShow\\" + _companyconstant.Value + "' onclick='imgDataNewsClick('" + _companyconstant.Value3 + "');' title='" + _companyconstant.Value2 + "'/></li>";
        }

        slideshow.InnerHtml = li;
    }

}